Karel (programming Language)
   HOME

TheInfoList



OR:

Karel is an
educational programming language An educational programming language is a programming language that is designed mostly as an instrument for learning, and less as a tool for writing programs to perform work. Types of educational programming languages Assembly languages Origi ...
for beginners, created by Richard E. Pattis in his book ''Karel The Robot: A Gentle Introduction to the Art of Programming''. Pattis used the language in his courses at Stanford University,
California California is a state in the Western United States, located along the Pacific Coast. With nearly 39.2million residents across a total area of approximately , it is the most populous U.S. state and the 3rd largest by area. It is also the m ...
. The language is named after
Karel Čapek Karel Čapek (; 9 January 1890 – 25 December 1938) was a Czech writer, playwright and critic. He has become best known for his science fiction, including his novel '' War with the Newts'' (1936) and play '' R.U.R.'' (''Rossum's Universal ...
, a
Czech Czech may refer to: * Anything from or related to the Czech Republic, a country in Europe ** Czech language ** Czechs, the people of the area ** Czech culture ** Czech cuisine * One of three mythical brothers, Lech, Czech, and Rus' Places * Czech, ...
writer who introduced the word ''
robot A robot is a machine—especially one programmable by a computer—capable of carrying out a complex series of actions automatically. A robot can be guided by an external control device, or the control may be embedded within. Robots may ...
'' in his play R.U.R.


Principles

A program in Karel is used to control a simple
robot A robot is a machine—especially one programmable by a computer—capable of carrying out a complex series of actions automatically. A robot can be guided by an external control device, or the control may be embedded within. Robots may ...
named Karel that lives in an environment consisting of a grid of streets (left-right) and avenues (up-down). Karel understands five basic instructions: move (Karel moves by one square in the direction he is facing), turnLeft (Karel turns 90 ° left), putBeeper (Karel puts a beeper on the square he is standing at), pickBeeper (Karel lifts a beeper off the square he is standing at), and turnoff (Karel switches himself off, the program ends). Karel can also perform boolean queries about his immediate environment, asking whether there is a beeper where he is standing, whether there are barriers next to him, and about the direction he is facing. A programmer can create additional instructions by defining them in terms of the five basic instructions, and by using conditional
control flow In computer science, control flow (or flow of control) is the order in which individual statements, instructions or function calls of an imperative program are executed or evaluated. The emphasis on explicit control flow distinguishes an ''im ...
statements if and while with environment queries, and by using the iterate construct.


Example

The following is a simple example of Karel syntax: BEGINNING-OF-PROGRAM   DEFINE turnRight AS BEGIN turnLeft; turnLeft; turnLeft; END   BEGINNING-OF-EXECUTION ITERATE 3 TIMES BEGIN turnRight; move END turnoff END-OF-EXECUTION   END-OF-PROGRAM


Variants and descendants

The language has inspired the development of various clones and similar educational languages. As the language is intended for beginners, localized variants exist in some languages, notably
Czech Czech may refer to: * Anything from or related to the Czech Republic, a country in Europe ** Czech language ** Czechs, the people of the area ** Czech culture ** Czech cuisine * One of three mythical brothers, Lech, Czech, and Rus' Places * Czech, ...
(the programming language was quite popular in
Czechoslovakia , rue, Чеськословеньско, , yi, טשעכאסלאוואקיי, , common_name = Czechoslovakia , life_span = 1918–19391945–1992 , p1 = Austria-Hungary , image_p1 ...
). The principles of Karel were updated to the
object-oriented programming Object-oriented programming (OOP) is a programming paradigm based on the concept of "objects", which can contain data and code. The data is in the form of fields (often known as attributes or ''properties''), and the code is in the form of ...
paradigm in a new programming language called Karel++. Karel++ is conceptually based on Karel, but uses a completely new syntax, similar to
Java Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's mos ...
. A REALbasic implementation, rbKarel, provides the basic Karel commands within an RBScript environment with BASIC syntax being used for loops and conditionals. This teaching project provides a cross-platform GUI for Karel experiments including single-stepping and spoken output. A Karel-inspired language and environment called ''Robot Emil'' uses a 3D view of the robot's world. ''Robot Emil'' offers a large palette of objects that can be placed to depict walls, windows (transparency), water and grass. The camera may be moved freely throughout the 3D environment. The robot may be controlled interactively with buttons in the GUI, or by programs written in Emil's Karel-like programming language. The author states that the program is free for use by schools, students and children. Versions are available in
English English usually refers to: * English language * English people English may also refer to: Peoples, culture, and language * ''English'', an adjective for something of, from, or related to England ** English national ide ...
,
Czech Czech may refer to: * Anything from or related to the Czech Republic, a country in Europe ** Czech language ** Czechs, the people of the area ** Czech culture ** Czech cuisine * One of three mythical brothers, Lech, Czech, and Rus' Places * Czech, ...
and Slovak. A proprietary language which is also called Karel is used to program the robots of
FANUC Robotics FANUC ( or ; often styled Fanuc) is a Japanese group of companies that provide automation products and services such as robotics and computer numerical control wireless systems. These companies are principally of Japan, Fanuc America Corporat ...
. However, FANUC Karel is derived from Pascal. The language has also been implemented as Karel the Dog in
JavaScript JavaScript (), often abbreviated as JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS. As of 2022, 98% of websites use JavaScript on the client side for webpage behavior, of ...
by CodeHS. Similar to the original language, this implementation features Karel in a grid world. Programmers use and build upon Karel's simple vocabulary of commands to accomplish programming tasks. Instead of putting and picking beepers, Karel the Dog puts and takes tennis balls. A German version of Karel is named "Robot Karol".


See also

*
Educational programming language An educational programming language is a programming language that is designed mostly as an instrument for learning, and less as a tool for writing programs to perform work. Types of educational programming languages Assembly languages Origi ...
* RoboMind - An attractive, educational alternative programming environment * RUR-PLE - another "learn Python" tool based on ideas in Karel * CodeHS - introductory computer science education using Karel in JavaScript


Further reading

* Richard E. Pattis. ''Karel The Robot: A Gentle Introduction to the Art of Programming''. John Wiley & Sons, 1981. . * Joseph Bergin, Mark Stehlik, Jim Roberts, Richard E. Pattis. ''Karel++: A Gentle Introduction to the Art of Object-Oriented Programming''. John Wiley & Sons, 1996. .


References

{{reflist


External links


Karel syntax

xKarel
by R. Dostal and P. Abrahamczik (created 1997)
Karel
by T. Mitchell (created 2000)
Karel in tiny-c
by Lee Bradley (created 2013)
Karel for iPad
by CloudMakers (created 2014)
Karel in JavaScript
by CodeHS
Karel in Perl 5
by E. Choroba (created 2016)
Karel-3D in JavaScript and C++ (sk) (en) (de) (es)
(created 2017, 2018)
Guido van Robot (GvR) - Karel in Python
(created 2006, 2010) Educational programming languages Procedural programming languages Programming languages created in 1981